﻿using Data0426.Base.Common;
using Data0426.Base.Dommain;
using Data0426.Base.Read.API.Applaction.Command;
using Data0426.Base.Read.API.DTO;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Data0426.Base.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LoginController : ControllerBase
    {
        private readonly IMediator mediator;

        public LoginController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<Accounts>> Login([FromQuery]LoginCommand request)
        {
            return mediator.Send(request);
        }

        [HttpPost]
        public Task<ApiResult<int>> createlogin(CreateLoginCommand request)
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 下拉
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<Indescs>>> ShowInde([FromQuery]ShowIndesCommand request)
        {
            return mediator.Send(request);
        }


        /// <summary>
        /// 显示表单分类
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<ApiPaging<List<ShowFormDTO>>>> Showform([FromQuery]ShowFormTypeCommand request)
        {
            return mediator.Send(request);
        }
    }
}
